/***************************************************************************
 *   Copyright (C) 2007 by Warren Kenny   *
 *   warren.kenny@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 
#ifndef OTA_CORE_H
#define OTA_CORE_H
 
#include <iostream>
#include <string>
#include <sstream>

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
 
#include <otaBytePacker.h>
#include <otaConfigReader.h>

typedef struct timeval otaTime;
 
enum otaMySQLMessageTypes
{
	OTA_MSG_TYPE_SERVER_HANDSHAKE = 0,
 	OTA_MSG_TYPE_CLIENT_CREDENTIALS,
  	OTA_MSG_TYPE_CLIENT_COMMAND,
   	OTA_MSG_TYPE_SERVER_RESPONSE,	
};

enum otaMySQLClientCommandTypes
{
	OTA_CLIENT_COMMAND_SLEEP = 0,          				// (none, this is an internal thread state)
	OTA_CLIENT_COMMAND_QUIT,            				// mysql_close
	OTA_CLIENT_COMMAND_INIT_DB,		         		// mysql_select_db 
	OTA_CLIENT_COMMAND_QUERY,           				// mysql_real_query
	OTA_CLIENT_COMMAND_FIELD_LIST,      				// mysql_list_fields
	OTA_CLIENT_COMMAND_CREATE_DB,      				// mysql_create_db (deprecated)
	OTA_CLIENT_COMMAND_DROP_DB,         				// mysql_drop_db (deprecated)
	OTA_CLIENT_COMMAND_REFRESH,         				// mysql_refresh
	OTA_CLIENT_COMMAND_SHUTDOWN,        				// mysql_shutdown
	OTA_CLIENT_COMMAND_STATISTICS,     				// mysql_stat
	OTA_CLIENT_COMMAND_PROCESS_INFO,    				// mysql_list_processes
	OTA_CLIENT_COMMAND_CONNECT,         				// (none, this is an internal thread state)
	OTA_CLIENT_COMMAND_PROCESS_KILL,    				// mysql_kill
	OTA_CLIENT_COMMAND_DEBUG,           				// mysql_dump_debug_info
	OTA_CLIENT_COMMAND_PING,            				// mysql_ping
	OTA_CLIENT_COMMAND_TIME,            				// (none, this is an internal thread state)
	OTA_CLIENT_COMMAND_DELAYED_INSERT,  				// (none, this is an internal thread state)
	OTA_CLIENT_COMMAND_CHANGE_USER,     				// mysql_change_user
	OTA_CLIENT_COMMAND_BINLOG_DUMP,     				// (used by slave server / mysqlbinlog)
	OTA_CLIENT_COMMAND_TABLE_DUMP,      				// (used by slave server to get master table)
	OTA_CLIENT_COMMAND_CONNECT_OUT,     				// (used by slave to log connection to master)
	OTA_CLIENT_COMMAND_REGISTER_SLAVE,  				// (used by slave to register to master)
	OTA_CLIENT_COMMAND_STMT_PREPARE,    				// mysql_stmt_prepare
	OTA_CLIENT_COMMAND_STMT_EXECUTE,    				// mysql_stmt_execute
	OTA_CLIENT_COMMAND_STMT_SEND_LONG_DATA, 				// mysql_stmt_send_long_data
	OTA_CLIENT_COMMAND_STMT_CLOSE,      				// mysql_stmt_close
	OTA_CLIENT_COMMAND_STMT_RESET,      				// mysql_stmt_reset
	OTA_CLIENT_COMMAND_SET_OPTION,      				// mysql_set_server_option
	OTA_CLIENT_COMMAND_STMT_FETCH,      				// mysql_stmt_fetch
 	OTA_CLIENT_COMMAND_IRRELEVANT,
};

enum otaMySQLServerResponseTypes
{
	OTA_SERVER_RESPONSE_ERROR = 0xFF,
 	OTA_SERVER_RESPONSE_OK = 0x00,
  	OTA_SERVER_RESPONSE_RESULT_DATA,
   	OTA_SERVER_RESPONSE_REFORMAT_PASSWORD = 254,
   	OTA_SERVER_RESPONSE_END_OF_FIELD = 0xFE,
};
 
#endif
